#include <stdio.h>
#include <assert.h>
#include <string.h>
char my_memmove(void*des,void*src,size_t n)
{
	assert(des);
	assert(src);
	char* ret = des;
	if (src < des)
	{
		(char*)src  = (char*)src + n-1;
		(char*)des = (char*)des + n-1;
		while (n)
		{
			*(char*)des = *(char*)src;
			des = (char*)des - 1;
			src = (char*)src - 1;
			n--;
		}
	}
	else {
		while (n)
		{
			*(char*)des = *(char*)src;
			des = (char*)des + 1;
			src = (char*)src + 1;
			n--;
		}
	
	}
	return ret;
}

int main()
{
	int arr1[] = { 1,2,3,4,5,6,7,8,9,10 };
	memmove(arr1, arr1+3, 20);
	int i = 0;
	for (i = 0; i < 10; i++)
	{
		printf("%d ", arr1[i]);
	}
	printf("\n");
	int arr2[] = { 1,2,3,4,5,6,7,8,9,10 };
	my_memmove(arr2 , arr2+3, 20);
	for (i = 0; i < 10; i++)
	{
		printf("%d ", arr2[i]);
	}
	return 0;
}